package modules.march
{
	import flash.events.MouseEvent;
	import modules.march.vo.ProjectVO;
	import ui.NewProjectUI;
	
	/**
	 * 新建地图对话框
	 * @author WLDragon 2014-01-05
	 */
	public class NewProject extends NewProjectUI
	{
		/**
		 * 新建地图的对话框
		 * @param	$refer 打开参考地图处理函数
		 * @param	$ok 新建地图编辑工程处理函数
		 */
		public function NewProject($refer:Function, $ok:Function, $cancel:Function)
		{
			super();
			
			mHandleRefer = $refer;
			mHandleOk = $ok;
			mHandleCancel = $cancel;
		}
		
		override protected function onClick(e:MouseEvent):void
		{
			switch (e.target.name)
			{
				case "lnkRefer": 
					mHandleRefer.call();
					break;
				case "lnkOk": 
					var vo:ProjectVO = new ProjectVO(txtName.text,int(txtRow.text),int(txtColumn.text),int(txtWidth.text),int(txtHeight.text),txtOutput.text);
					mHandleOk.call(null, vo);
					close();
					break;
				case "lnkCancel": 
					mHandleCancel.call();
					close();
					break;
				default: 
			}
		}
		
		public function setParams(value:ProjectVO):void 
		{
			txtName.text = value.name;
			txtRow.text = value.r.toString();
			txtColumn.text = value.c.toString();
			txtWidth.text = value.w.toString();
			txtHeight.text = value.h.toString();
			txtOutput.text = value.path;
		}
		
		private var mHandleRefer:Function;
		private var mHandleOk:Function;
		private var mHandleCancel:Function;
	}

}